package com.cyjt.operation.adapter;

import java.util.List;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.cyjt.operation.R;
import com.cyjt.operation.bean.SimStatusInfo;

/**
 * 3G路由列表的Adapter
 * 
 * @author wsw
 * 
 */
public class SimInfoListAdapter extends BaseAdapter {
	private Activity activity;
	private List<SimStatusInfo> simInfoList;

	public SimInfoListAdapter(Activity context, List<SimStatusInfo> simInfoList) {
		this.activity = context;
		this.simInfoList = simInfoList;
	}

	@Override
	public int getCount() {
		return simInfoList.size();
	}

	@Override
	public Object getItem(int position) {
		return simInfoList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	public class ViewHolder {
		private TextView routing_item_num, routing_item_time, routing_item_status;
	}

	@SuppressLint("InflateParams")
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = LayoutInflater.from(activity);
		ViewHolder viewHolder = null;
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.list_view_item_for_routing_status, null);
			viewHolder = new ViewHolder();
			viewHolder.routing_item_num = (TextView) convertView.findViewById(R.id.routing_item_num);
			viewHolder.routing_item_time = (TextView) convertView.findViewById(R.id.routing_item_time);
			viewHolder.routing_item_status = (TextView) convertView.findViewById(R.id.routing_item_status);
			convertView.setTag(viewHolder);
		} else
			viewHolder = (ViewHolder) convertView.getTag();
		SimStatusInfo simInfo = simInfoList.get(position);
		viewHolder.routing_item_num.setText(simInfo.getSimNo() + "");
		viewHolder.routing_item_time.setText(simInfo.getEndAtToString().substring(0, 10));// 仅存到天
		viewHolder.routing_item_status.setText(simInfo.getTimeFromNow() + "");
		return convertView;
	}

}
